package com.lovestacks.tj.dao;

import com.lovestacks.tj.bean.NewMediaOperation;
import com.lovestacks.tj.bean.PersonInfomation;
import org.apache.ibatis.annotations.*;

import java.util.List;

/***
 * 新媒体的dao层NewMediaOperationDao
 */
public interface NewMediaOperationDao {

    //插入新媒体的一条信息
    @Insert("insert into new_media_operation(OPEN_ID,KIND,KIND_INFO,DEPARTMENT,ENTERPRISES,STATUS) values(#{openId},#{kind},#{kindInfo},#{department},#{enterprises},#{status})")
    public int insertNewMediaOperation(NewMediaOperation newMediaOperation);
    @Update("update new_media_operation set KIND_INFO = #{kindInfo} , STATUS = #{status} , OPEN_ID = #{openId} where ID = #{ID}")
    public int updateNewMediaOperation(NewMediaOperation newMediaOperation);

    //获取新媒体的一条信息
    @Results({
            @Result(property = "openId", column = "OPEN_ID"),
            @Result(property = "kind", column = "KIND"),
            @Result(property = "kindInfo", column = "KIND_INFO"),
            @Result(property = "department", column = "DEPARTMENT"),
            @Result(property = "enterprises", column = "ENTERPRISES"),
            @Result(property = "status", column = "STATUS"),
            @Result(property = "creatDate", column = "CREAT_DATE"),
            @Result(property = "lastUpdateDate", column = "LAST_UPDATE"),
    })
    @Select("select * from new_media_operation where KIND = #{kind} AND DEPARTMENT = #{department} AND ENTERPRISES = #{enterprises}")
    public List<NewMediaOperation> getNewMediaOperation(NewMediaOperation newMediaOperation);

    //获取新媒体的一条信息
    @Results({
            @Result(property = "openId", column = "OPEN_ID"),
            @Result(property = "kind", column = "KIND"),
            @Result(property = "kindInfo", column = "KIND_INFO"),
            @Result(property = "department", column = "DEPARTMENT"),
            @Result(property = "enterprises", column = "ENTERPRISES"),
            @Result(property = "status", column = "STATUS"),
            @Result(property = "creatDate", column = "CREAT_DATE"),
            @Result(property = "lastUpdateDate", column = "LAST_UPDATE"),
    })
    @Select("select * from new_media_operation where  DEPARTMENT = #{department} AND ENTERPRISES = #{enterprises}")
    public List<NewMediaOperation> getScanList(NewMediaOperation newMediaOperation);
    //获取新媒体的一条信息
    @Results({
            @Result(property = "openId", column = "OPEN_ID"),
            @Result(property = "kind", column = "KIND"),
            @Result(property = "kindInfo", column = "KIND_INFO"),
            @Result(property = "department", column = "DEPARTMENT"),
            @Result(property = "enterprises", column = "ENTERPRISES"),
            @Result(property = "status", column = "STATUS"),
            @Result(property = "creatDate", column = "CREAT_DATE"),
            @Result(property = "lastUpdateDate", column = "LAST_UPDATE"),
    })
    @Select("select * from new_media_operation where ID = #{id} ")
    public NewMediaOperation getNewMediaOperationByID(int id);
    //查询当前新媒体的数量（是否在数据库中已经创建）
    @Select("select count(*) from new_media_operation where  KIND = #{kind} AND DEPARTMENT = #{department} AND ENTERPRISES = #{enterprises}")
    public int getNewMediaOperationNum(NewMediaOperation newMediaOperation);



}
